home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / comm2 / termsorc.lha / Extras / Source / term-source.lha / PhonePanelPlus.c < prev    next >
C/C++ Source or Header  |  1995-09-26  |  17KB  |  769 lines

  1. /*
  2. **    PhonePanelPlus.c
  3. **
  4. **    The phonebook and support routines
  5. **
  6. **    Copyright © 1990-1995 by Olaf `Olsen' Barthel
  7. **        All Rights Reserved
  8. **
  9. **    :ts=4
  10. */
  11.  
  12. #include "termGlobal.h"
  13.  
  14.     // The gadget IDs are in there
  15.  
  16. #include "PhonePanel.h"
  17.  
  18.     /* PhoneListViewRender():
  19.      *
  20.      *    This callback routine is responsible for rendering
  21.      *    the single listview entries.
  22.      */
  23.  
  24. ULONG __saveds __asm
  25. PhoneListViewRender(register __a0 struct Hook *Hook,register __a1 struct LVDrawMsg *Msg,register __a2 struct PhoneNode *Node)
  26. {
  27.         /* We only know how to redraw lines. */
  28.  
  29.     if(Msg -> lvdm_MethodID == LV_DRAW)
  30.     {
  31.         struct RastPort    *RPort    = Msg -> lvdm_RastPort;
  32.         LONG             Count    = Node -> Entry -> Count + 1,
  33.                          Left    = Msg -> lvdm_Bounds . MinX,
  34.                          Top    = Msg -> lvdm_Bounds . MinY,
  35.                          Width    = Msg -> lvdm_Bounds . MaxX - Msg -> lvdm_Bounds . MinX + 1,
  36.                          Height    = Msg -> lvdm_Bounds . MaxY - Msg -> lvdm_Bounds . MinY + 1,
  37.                          FgPen,BgPen,
  38.                          Template,
  39.                          Len,LabelLen;
  40.         UBYTE             String[80],Num[8];
  41.  
  42.             /* Determine the rendering pens. */
  43.  
  44.         switch(Msg -> lvdm_State)
  45.         {
  46.             case LVR_SELECTEDDISABLED:
  47.             case LVR_NORMALDISABLED:
  48.             case LVR_NORMAL:
  49.  
  50.                 FgPen = Msg -> lvdm_DrawInfo -> dri_Pens[TEXTPEN];
  51.                 BgPen = Msg -> lvdm_DrawInfo -> dri_Pens[BACKGROUNDPEN];
  52.                 break;
  53.  
  54.             case LVR_SELECTED:
  55.  
  56.                 FgPen = Msg -> lvdm_DrawInfo -> dri_Pens[FILLTEXTPEN];
  57.                 BgPen = Msg -> lvdm_DrawInfo -> dri_Pens[FILLPEN];
  58.                 break;
  59.         }
  60.  
  61.         if(Count > 0)
  62.         {
  63.             if(Msg -> lvdm_DrawInfo -> dri_Pens[HIGHLIGHTTEXTPEN] != BgPen)
  64.                 FgPen = Msg -> lvdm_DrawInfo -> dri_Pens[HIGHLIGHTTEXTPEN];
  65.         }
  66.  
  67.         SetAPen(RPort,BgPen);
  68.         RectFill(RPort,Left,Top,Left + 1,Top + Height - 1);
  69.  
  70.         Left    += 2;
  71.         Width    -= 2;
  72.  
  73.             /* Determine maximum index text length. */
  74.  
  75.         Template = 3 * ((ULONG)Hook -> h_Data) + TextLength(RPort," - ",3);
  76.  
  77.             /* Get the vanilla name. */
  78.  
  79.         strcpy(String,&Node -> VanillaNode . ln_Name[6]);
  80.  
  81.             /* Set the rendering pens. */
  82.  
  83.         SetDrMd(RPort,JAM2);
  84.         SetBPen(RPort,BgPen);
  85.  
  86.             /* Has this entry been selected? */
  87.  
  88.         if(Count > 0)
  89.         {
  90.             LONG Delta;
  91.  
  92.                 /* Set up the header. */
  93.  
  94.             SPrintf(Num,"%3ld - ",Count);
  95.  
  96.                 /* Determine header length. */
  97.  
  98.             Len = TextLength(RPort,Num,6);
  99.  
  100.                 /* Fill the space to precede the header. */
  101.  
  102.             if((Delta = Template - Len) > 0)
  103.             {
  104.                 SetAPen(RPort,BgPen);
  105.                 RectFill(RPort,Left,Top,Left + Delta - 1,Top + Height - 1);
  106.             }
  107.  
  108.                 /* Render the header, right-justified. */
  109.  
  110.             SetAPen(RPort,FgPen);
  111.  
  112.             Move(RPort,Left + Delta,Top + RPort -> Font -> tf_Baseline);
  113.             Text(RPort,Num,6);
  114.         }
  115.         else
  116.         {
  117.                 /* Fill the blank space to precede the vanilla name. */
  118.  
  119.             SetAPen(RPort,BgPen);
  120.             RectFill(RPort,Left,Top,Left + Template - 1,Top + Height - 1);
  121.             SetAPen(RPort,FgPen);
  122.         }
  123.  
  124.             /* Adjust width and area left edge. */
  125.  
  126.         Left    += Template;
  127.         Width    -= Template;
  128.  
  129.             /* Determine length of vanilla name. */
  130.  
  131.         LabelLen = strlen(String);
  132.  
  133.             /* Try to make it fit. */
  134.  
  135.         while(LabelLen > 0 && (Len = TextLength(RPort,String,LabelLen)) > Width)
  136.             LabelLen--;
  137.  
  138.             /* Print the vanilla name if possible. */
  139.  
  140.         if(LabelLen)
  141.         {
  142.             Move(RPort,Left,Top + RPort -> Font -> tf_Baseline);
  143.             Text(RPort,String,LabelLen);
  144.  
  145.             Left    += Len;
  146.             Width    -= Len;
  147.         }
  148.  
  149.             /* Fill the area to follow the vanilla name. */
  150.  
  151.         if(Width > 0)
  152.         {
  153.             SetAPen(RPort,BgPen);
  154.             RectFill(RPort,Left,Top,Left + Width - 1,Top + Height - 1);
  155.         }
  156.  
  157.             /* If the item happens to be disabled, draw the cross-hatch
  158.              * pattern across it.
  159.              */
  160.  
  161.         if(Msg -> lvdm_State == LVR_SELECTEDDISABLED || Msg -> lvdm_State == LVR_NORMALDISABLED)
  162.         {
  163.             SetDrMd(RPort,JAM1);
  164.  
  165.             SetAPen(RPort,Msg -> lvdm_DrawInfo -> dri_Pens[BLOCKPEN]);
  166.  
  167.             SetAfPt(RPort,(UWORD *)&Ghosting,1);
  168.  
  169.             RectFill(RPort,Msg -> lvdm_Bounds . MinX,Msg -> lvdm_Bounds . MinY,Msg -> lvdm_Bounds . MaxX,Msg -> lvdm_Bounds . MaxY);
  170.  
  171.             SetAfPt(RPort,NULL,0);
  172.         }
  173.  
  174.         return(LVCB_OK);
  175.     }
  176.     else
  177.         return(LVCB_UNKNOWN);
  178. }
  179.  
  180. BOOLEAN
  181. SaveChanges(struct Window *Parent)
  182. {
  183.     return((BOOLEAN)MyEasyRequest(Parent,LocaleString(MSG_SAVE_CHANGES),LocaleString(MSG_GLOBAL_YES_NO_TXT)));
  184. }
  185.  
  186. BYTE __regargs
  187. EditConfig(struct Configuration *Config,LONG Type,ULONG Qualifier,struct Window *Window)
  188. {
  189.     STATIC LONG TypeMappings[15][2] =
  190.     {
  191.         GAD_SERIAL_EDIT,        PREF_SERIAL,
  192.         GAD_MODEM_EDIT,            PREF_MODEM,
  193.         GAD_SCREEN_EDIT,        PREF_SCREEN,
  194.         GAD_TERMINAL_EDIT,        PREF_TERMINAL,
  195.         GAD_EMULATION_EDIT,        PREF_EMULATION,
  196.         GAD_CLIPBOARD_EDIT,        PREF_CLIP,
  197.         GAD_CAPTURE_EDIT,        PREF_CAPTURE,
  198.         GAD_COMMAND_EDIT,        PREF_COMMAND,
  199.         GAD_MISC_EDIT,            PREF_MISC,
  200.         GAD_PATH_EDIT,            PREF_PATH,
  201.         GAD_TRANSFER_EDIT,        PREF_TRANSFER,
  202.         GAD_TRANSLATION_EDIT,    PREF_TRANSLATIONFILENAME,
  203.         GAD_MACRO_EDIT,            PREF_MACROFILENAME,
  204.         GAD_CURSOR_EDIT,        PREF_CURSORFILENAME,
  205.         GAD_FASTMACRO_EDIT,        PREF_FASTMACROFILENAME
  206.     };
  207.  
  208.     struct FileRequester    *FileRequest;
  209.     UBYTE                     DummyBuffer[MAX_FILENAME_LENGTH],
  210.                             *DummyChar;
  211.     BOOLEAN                     Changed    = FALSE,
  212.                              Default    = FALSE,
  213.                              FallBack    = TRUE;
  214.     LONG                     PrefType;
  215.     WORD                     i;
  216.     APTR                     Data;
  217.  
  218.         // Find the prefs fragment that should be worked upon
  219.  
  220.     for(i = 0 ; i < sizeof(TypeMappings) / (sizeof(LONG) * 2) ; i++)
  221.     {
  222.         if(TypeMappings[i][0] == Type)
  223.         {
  224.             PrefType = TypeMappings[i][1];
  225.  
  226.             break;
  227.         }
  228.     }
  229.  
  230.     Data = GetConfigEntry(Config,PrefType);
  231.  
  232.     if(CreateConfigEntry(Config,PrefType))
  233.     {
  234.         if(!Data)
  235.             ResetConfigEntry(Config,PrefType,FALSE);
  236.  
  237.         switch(Type)
  238.         {
  239.             case GAD_SERIAL_EDIT:
  240.  
  241.                 Changed = SerialPanel(Config,&Default);
  242.                 break;
  243.  
  244.             case GAD_MODEM_EDIT:
  245.  
  246.                 Changed = ModemPanel(Config,&Default);
  247.                 break;
  248.  
  249.             case GAD_SCREEN_EDIT:
  250.  
  251.                 Changed = ScreenPanel(Config,&Default);
  252.                 break;
  253.  
  254.             case GAD_TERMINAL_EDIT:
  255.  
  256.                 Changed = TerminalPanel(Config,&Default);
  257.                 break;
  258.  
  259.             case GAD_EMULATION_EDIT:
  260.  
  261.                 Changed = EmulationPanel(Config,&Default);
  262.                 break;
  263.  
  264.             case GAD_CLIPBOARD_EDIT:
  265.  
  266.                 Changed = ClipPanel(Config,&Default);
  267.                 break;
  268.  
  269.             case GAD_CAPTURE_EDIT:
  270.  
  271.                 Changed = CapturePanel(Config,&Default);
  272.                 break;
  273.  
  274.             case GAD_COMMAND_EDIT:
  275.  
  276.                 Changed = CommandPanel(Config,&Default);
  277.                 break;
  278.  
  279.             case GAD_MISC_EDIT:
  280.  
  281.                 Changed = MiscPanel(Config,&Default);
  282.                 break;
  283.  
  284.             case GAD_PATH_EDIT:
  285.  
  286.                 Changed = PathPanel(Config,&Default);
  287.                 break;
  288.  
  289.             case GAD_TRANSFER_EDIT:
  290.  
  291.                 Changed = LibPanel(Config,&Default);
  292.                 break;
  293.  
  294.             case GAD_TRANSLATION_EDIT:
  295.  
  296.                 if(!(Qualifier & (IEQUALIFIER_LSHIFT | IEQUALIFIER_RSHIFT)))
  297.                 {
  298.                     struct TranslationEntry **Send,**Receive = NULL;
  299.                     BOOLEAN            Success = FALSE;
  300.  
  301.                     strcpy(DummyBuffer,Config -> TranslationFileName);
  302.  
  303.                     if(Send = AllocTranslationTable())
  304.                     {
  305.                         if(Receive = AllocTranslationTable())
  306.                         {
  307.                             Success = TRUE;
  308.  
  309.                             if(DummyBuffer[0])
  310.                             {
  311.                                 if(!LoadTranslationTables(DummyBuffer,Send,Receive))
  312.                                 {
  313.                                     ShowError(Window,ERR_LOAD_ERROR,IoErr(),DummyBuffer);
  314.  
  315.                                     FillTranslationTable(Send);
  316.                                     FillTranslationTable(Receive);
  317.                                 }
  318.                             }
  319.                             else
  320.                             {
  321.                                 FillTranslationTable(Send);
  322.                                 FillTranslationTable(Receive);
  323.                             }
  324.                         }
  325.                     }
  326.  
  327.                     if(Success)
  328.                     {
  329.                         if(TranslationPanel(&Send,&Receive,DummyBuffer,Window,NULL))
  330.                         {
  331.                             if(Send || Receive)
  332.                             {
  333.                                 if(IsStandardTable(Send) && IsStandardTable(Receive))
  334.                                     DummyBuffer[0] = 0;
  335.  
  336.                                 if(DummyBuffer[0])
  337.                                 {
  338.                                     if(SaveChanges(Window))
  339.                                     {
  340.                                         if(!SaveTranslationTables(DummyBuffer,Send,Receive))
  341.                                             ShowError(Window,ERR_SAVE_ERROR,IoErr(),DummyBuffer);
  342.                                     }
  343.                                 }
  344.                             }
  345.                             else
  346.                                 DummyBuffer[0] = 0;
  347.                         }
  348.  
  349.                         if(strcmp(Config -> TranslationFileName,DummyBuffer))
  350.                         {
  351.                             strcpy(Config -> TranslationFileName,DummyBuffer);
  352.  
  353.                             Changed = TRUE;
  354.                         }
  355.  
  356.                         FallBack = FALSE;
  357.                     }
  358.  
  359.                     if(Send)
  360.                         FreeTranslationTable(Send);
  361.  
  362.                     if(Receive)
  363.                         FreeTranslationTable(Receive);
  364.                 }
  365.  
  366.                 if(FallBack)
  367.                 {
  368.                     SplitFileName(Config -> TranslationFileName,&DummyChar,DummyBuffer);
  369.  
  370.                     if(FileRequest = GetFile(Window,LocaleString(MSG_PHONEPANEL_SELECT_TRANSLATION_TXT),DummyBuffer,DummyChar,DummyBuffer,"#?.prefs",FALSE,FALSE,FALSE,LocaleString(MSG_GLOBAL_SELECT_TXT),TRUE))
  371.                     {
  372.                         strcpy(Config -> TranslationFileName,DummyBuffer);
  373.  
  374.                         FreeAslRequest(FileRequest);
  375.  
  376.                         Changed = TRUE;
  377.                     }
  378.                 }
  379.  
  380.                 break;
  381.  
  382.             case GAD_MACRO_EDIT:
  383.  
  384.                 if(!(Qualifier & (IEQUALIFIER_LSHIFT | IEQUALIFIER_RSHIFT)))
  385.                 {
  386.                     struct MacroKeys *Keys;
  387.  
  388.                     if(Keys = (struct MacroKeys *)AllocVecPooled(sizeof(struct MacroKeys),MEMF_ANY | MEMF_CLEAR))
  389.                     {
  390.                         strcpy(DummyBuffer,Config -> MacroFileName);
  391.  
  392.                         if(DummyBuffer[0])
  393.                         {
  394.                             if(!LoadMacros(DummyBuffer,Keys))
  395.                                 ShowError(Window,ERR_LOAD_ERROR,IoErr(),DummyBuffer);
  396.                         }
  397.  
  398.                         if(MacroPanel(Keys,DummyBuffer,FALSE,Window,NULL))
  399.                         {
  400.                             if(SaveChanges(Window))
  401.                             {
  402.                                 if(!WriteIFFData(DummyBuffer,Keys,sizeof(struct MacroKeys),ID_KEYS))
  403.                                     ShowError(Window,ERR_SAVE_ERROR,IoErr(),DummyBuffer);
  404.                             }
  405.                         }
  406.  
  407.                         if(strcmp(Config -> MacroFileName,DummyBuffer))
  408.                         {
  409.                             strcpy(Config -> MacroFileName,DummyBuffer);
  410.  
  411.                             Changed = TRUE;
  412.                         }
  413.  
  414.                         FallBack = FALSE;
  415.  
  416.                         FreeVecPooled(Keys);
  417.                     }
  418.                 }
  419.  
  420.                 if(FallBack)
  421.                 {
  422.                     SplitFileName(Config -> MacroFileName,&DummyChar,DummyBuffer);
  423.  
  424.                     if(FileRequest = GetFile(Window,LocaleString(MSG_PHONEPANEL_SELECT_KEYBOARD_MACROS_TXT),DummyBuffer,DummyChar,DummyBuffer,"#?.prefs",FALSE,FALSE,FALSE,LocaleString(MSG_GLOBAL_SELECT_TXT),TRUE))
  425.                     {
  426.                         strcpy(Config -> MacroFileName,DummyBuffer);
  427.  
  428.                         FreeAslRequest(FileRequest);
  429.  
  430.                         Changed = TRUE;
  431.                     }
  432.                 }
  433.  
  434.                 break;
  435.  
  436.             case GAD_CURSOR_EDIT:
  437.  
  438.                 if(!(Qualifier & (IEQUALIFIER_LSHIFT | IEQUALIFIER_RSHIFT)))
  439.                 {
  440.                     struct CursorKeys *Keys;
  441.  
  442.                     if(Keys = (struct CursorKeys *)AllocVecPooled(sizeof(struct CursorKeys),MEMF_ANY | MEMF_CLEAR))
  443.                     {
  444.                         strcpy(DummyBuffer,Config -> CursorFileName);
  445.  
  446.                         if(DummyBuffer[0])
  447.                         {
  448.                             if(!ReadIFFData(DummyBuffer,Keys,sizeof(struct CursorKeys),ID_KEYS))
  449.                             {
  450.                                 ResetCursorKeys(Keys);
  451.  
  452.                                 ShowError(Window,ERR_LOAD_ERROR,IoErr(),DummyBuffer);
  453.                             }
  454.                         }
  455.                         else
  456.                             ResetCursorKeys(Keys);
  457.  
  458.                         if(CursorPanel(Keys,DummyBuffer,Window,NULL))
  459.                         {
  460.                             if(SaveChanges(Window))
  461.                             {
  462.                                 if(!WriteIFFData(DummyBuffer,Keys,sizeof(struct CursorKeys),ID_KEYS))
  463.                                     ShowError(Window,ERR_SAVE_ERROR,IoErr(),DummyBuffer);
  464.                             }
  465.                         }
  466.  
  467.                         if(strcmp(Config -> CursorFileName,DummyBuffer))
  468.                         {
  469.                             strcpy(Config -> CursorFileName,DummyBuffer);
  470.  
  471.                             Changed = TRUE;
  472.                         }
  473.  
  474.                         FallBack = FALSE;
  475.  
  476.                         FreeVecPooled(Keys);
  477.                     }
  478.                 }
  479.  
  480.                 if(FallBack)
  481.                 {
  482.                     SplitFileName(Config -> CursorFileName,&DummyChar,DummyBuffer);
  483.  
  484.                     if(FileRequest = GetFile(Window,LocaleString(MSG_PHONEPANEL_SELECT_CURSOR_KEYS_TXT),DummyBuffer,DummyChar,DummyBuffer,"#?.prefs",FALSE,FALSE,FALSE,LocaleString(MSG_GLOBAL_SELECT_TXT),TRUE))
  485.                     {
  486.                         strcpy(Config -> CursorFileName,DummyBuffer);
  487.  
  488.                         FreeAslRequest(FileRequest);
  489.  
  490.                         Changed = TRUE;
  491.                     }
  492.                 }
  493.  
  494.                 break;
  495.  
  496.             case GAD_FASTMACRO_EDIT:
  497.  
  498.                 if(!(Qualifier & (IEQUALIFIER_LSHIFT | IEQUALIFIER_RSHIFT)))
  499.                 {
  500.                     struct List *List;
  501.  
  502.                     if(List = CreateList())
  503.                     {
  504.                         strcpy(DummyBuffer,Config -> FastMacroFileName);
  505.  
  506.                         if(DummyBuffer[0])
  507.                         {
  508.                             if(!LoadFastMacros(DummyBuffer,List))
  509.                                 ShowError(Window,ERR_LOAD_ERROR,IoErr(),DummyBuffer);
  510.                         }
  511.  
  512.                         if(FastMacroPanel(List,DummyBuffer,Window,NULL))
  513.                         {
  514.                             if(SaveChanges(Window))
  515.                             {
  516.                                 if(!SaveFastMacros(DummyBuffer,List))
  517.                                     ShowError(Window,ERR_SAVE_ERROR,IoErr(),DummyBuffer);
  518.                             }
  519.                         }
  520.  
  521.                         if(strcmp(Config -> FastMacroFileName,DummyBuffer))
  522.                         {
  523.                             strcpy(Config -> FastMacroFileName,DummyBuffer);
  524.  
  525.                             Changed = TRUE;
  526.                         }
  527.  
  528.                         FallBack = FALSE;
  529.  
  530.                         DeleteList(List);
  531.                     }
  532.                 }
  533.  
  534.                 if(FallBack)
  535.                 {
  536.                     SplitFileName(Config -> FastMacroFileName,&DummyChar,DummyBuffer);
  537.  
  538.                     if(FileRequest = GetFile(Window,LocaleString(MSG_PHONEPANEL_SELECT_FAST_MACROS_TXT),DummyBuffer,DummyChar,DummyBuffer,"#?.prefs",FALSE,FALSE,FALSE,LocaleString(MSG_GLOBAL_SELECT_TXT),TRUE))
  539.                     {
  540.                         strcpy(Config -> FastMacroFileName,DummyBuffer);
  541.  
  542.                         FreeAslRequest(FileRequest);
  543.  
  544.                         Changed = TRUE;
  545.                     }
  546.                 }
  547.  
  548.                 break;
  549.         }
  550.  
  551.         if((!Changed && !Data) || Default)
  552.         {
  553.             DeleteConfigEntry(Config,PrefType);
  554.  
  555.             if(Default)
  556.                 Changed = TRUE;
  557.         }
  558.     }
  559.     else
  560.         DisplayBeep(Window -> WScreen);
  561.  
  562.     return(Changed);
  563. }
  564.  
  565. BOOLEAN __regargs
  566. ChangeState(LONG Type,UWORD Default,struct PhoneNode *Node)
  567. {
  568.     STATIC LONG TypeMappings[][2] =
  569.     {
  570.         GAD_SERIAL_STATE,        PREF_SERIAL,
  571.         GAD_MODEM_STATE,        PREF_MODEM,
  572.         GAD_SCREEN_STATE,        PREF_SCREEN,
  573.         GAD_TERMINAL_STATE,        PREF_TERMINAL,
  574.         GAD_EMULATION_STATE,    PREF_EMULATION,
  575.         GAD_CLIPBOARD_STATE,    PREF_CLIP,
  576.         GAD_CAPTURE_STATE,        PREF_CAPTURE,
  577.         GAD_COMMAND_STATE,        PREF_COMMAND,
  578.         GAD_MISC_STATE,            PREF_MISC,
  579.         GAD_PATH_STATE,            PREF_PATH,
  580.         GAD_TRANSFER_STATE,        PREF_TRANSFER,
  581.         GAD_TRANSLATION_STATE,    PREF_TRANSLATIONFILENAME,
  582.         GAD_MACRO_STATE,        PREF_MACROFILENAME,
  583.         GAD_CURSOR_STATE,        PREF_CURSORFILENAME,
  584.         GAD_FASTMACRO_STATE,    PREF_FASTMACROFILENAME,
  585.         GAD_RATE_STATE,            PREF_RATES
  586.     };
  587.  
  588.     struct Configuration    *LocalConfig;
  589.     LONG                     PrefType;
  590.     WORD                     i;
  591.     APTR                     Data;
  592.  
  593.         // Find the prefs fragment that should be worked upon
  594.  
  595.     for(i = 0 ; i < sizeof(TypeMappings) / (sizeof(LONG) * 2) ; i++)
  596.     {
  597.         if(TypeMappings[i][0] == Type)
  598.         {
  599.             PrefType = TypeMappings[i][1];
  600.  
  601.             break;
  602.         }
  603.     }
  604.  
  605.         // This is the one we're about to put through the wringer
  606.  
  607.     LocalConfig = Node -> Entry -> Config;
  608.  
  609.         // Get a pointer to it
  610.  
  611.     Data = GetConfigEntry(LocalConfig,PrefType);
  612.  
  613.         // A special case, the phone rates
  614.  
  615.     if(PrefType == PREF_RATES)
  616.     {
  617.         if(Default)
  618.         {
  619.                 // There will be some rates...
  620.  
  621.             Node -> Entry -> Header -> NoRates = FALSE;
  622.  
  623.                 // Nothing in this list?
  624.  
  625.             if(!Node -> Entry -> TimeDateList . mlh_Head -> mln_Succ)
  626.             {
  627.                 struct TimeDateNode *TimeDateNode;
  628.  
  629.                     // Provide defaults
  630.  
  631.                 if(TimeDateNode = CreateTimeDateNode(-1,-1,"",2))
  632.                     AddTail((struct List *)&Node -> Entry -> TimeDateList,&TimeDateNode -> VanillaNode);
  633.                 else
  634.                 {
  635.                     Node -> Entry -> Header -> NoRates = TRUE;    // Sorry, guv'nor
  636.  
  637.                     return(FALSE);
  638.                 }
  639.             }
  640.         }
  641.         else
  642.         {
  643.                 // Discard the time/date list
  644.  
  645.             FreeTimeDateList((struct List *)&Node -> Entry -> TimeDateList);
  646.  
  647.                 // No rates here
  648.  
  649.             Node -> Entry -> Header -> NoRates = TRUE;
  650.         }
  651.  
  652.         return(TRUE);
  653.     }
  654.  
  655.         // Default == TRUE means: replace fragment with a copy of the
  656.         //                        current global configuration which the
  657.         //                        user can edit later. Making a connection
  658.         //                        through the phonebook will cause the
  659.         //                        global configuration to be replaced
  660.         //                        with this copy.
  661.  
  662.     if(Default)
  663.     {
  664.         BOOLEAN Result;
  665.  
  666.             // Get rid of the old stuff
  667.  
  668.         if(Data)
  669.         {
  670.             DeleteConfigEntry(LocalConfig,PrefType);
  671.  
  672.             Result = TRUE;
  673.         }
  674.         else
  675.             Result = FALSE;
  676.  
  677.             // Create a new fragment with default values
  678.  
  679.         if(!CreateConfigEntry(LocalConfig,PrefType))
  680.             return(Result);
  681.     }
  682.     else
  683.     {
  684.             // Default == FALSE means: discard this fragment; making a
  685.             //                         connection through the phonebook
  686.             //                         will then leave these main config
  687.             //                         fragments unmodified.
  688.  
  689.         if(Data)
  690.             DeleteConfigEntry(LocalConfig,PrefType);
  691.         else
  692.             return(FALSE);
  693.     }
  694.  
  695.     return(TRUE);
  696. }
  697.  
  698. STRPTR *
  699. BuildLabels()
  700. {
  701.     LONG         Count;
  702.     struct Node    *Node;
  703.     STRPTR        *Labels;
  704.     LONG         i;
  705.  
  706.     for(Count = 0, Node = (struct Node *)PhoneGroupList . mlh_Head ; Node -> ln_Succ ; Node = Node -> ln_Succ)
  707.         Count++;
  708.  
  709.     if(!(Labels = (STRPTR *)AllocVecPooled(sizeof(STRPTR) * (Count + 2),MEMF_ANY)))
  710.         return(NULL);
  711.  
  712.     Labels[0] = LocaleString(MSG_PHONEBOOK_ALL_GROUP_TXT);
  713.  
  714.     for(i = 1, Node = (struct Node *)PhoneGroupList . mlh_Head ; Node -> ln_Succ ; Node = Node -> ln_Succ)
  715.         Labels[i++] = Node -> ln_Name;
  716.  
  717.     Labels[i] = NULL;
  718.  
  719.     return(Labels);
  720. }
  721.  
  722. VOID __regargs
  723. FindGroup(struct List **pCurrentList,LONG *pSelected,ULONG *pGrouper,struct List *PhoneList,struct MinList *List,struct PhoneNode *This)
  724. {
  725.     PhoneGroupNode        *GroupNode;
  726.     struct PhoneNode    *Node;
  727.     LONG                 Index;
  728.     ULONG                 Group;
  729.  
  730.     Group = 1;
  731.  
  732.     for(GroupNode = (PhoneGroupNode *)List -> mlh_Head ; GroupNode -> Node . ln_Succ ; GroupNode = (PhoneGroupNode *)GroupNode -> Node . ln_Succ)
  733.     {
  734.         Index = 0;
  735.  
  736.         for(Node = (struct PhoneNode *)GroupNode -> GroupList . mlh_Head ; Node -> VanillaNode . ln_Succ ; Node = (struct PhoneNode *)Node -> VanillaNode . ln_Succ)
  737.         {
  738.             if(Node == This)
  739.             {
  740.                 *pCurrentList    = (struct List *)&GroupNode -> GroupList;
  741.                 *pSelected        = Index;
  742.                 *pGrouper        = Group;
  743.  
  744.                 return;
  745.             }
  746.  
  747.             Index++;
  748.         }
  749.  
  750.         Group++;
  751.     }
  752.  
  753.     Index = 0;
  754.  
  755.     for(Node = (struct PhoneNode *)PhoneList -> lh_Head ; Node -> VanillaNode . ln_Succ ; Node = (struct PhoneNode *)Node -> VanillaNode . ln_Succ)
  756.     {
  757.         if(Node == This)
  758.         {
  759.             *pCurrentList    = PhoneList;
  760.             *pSelected        = Index;
  761.             *pGrouper        = 0;
  762.  
  763.             return;
  764.         }
  765.  
  766.         Index++;
  767.     }
  768. }
  769.